import 'package:flutter/material.dart';
import 'package:demo/EMPABEmployeeDepartment.dart';

/// EMPABEmployeeModel - 员工模型，包含了员工的详细信息和部门职位等数据
class EMPABEmployeeModel {

  @override
  String toString() {
    return 'EMPABEmployeeModel(deptId: $deptId, deptName: $deptName, dutyName: $dutyName, email: $email, '
        'gender: $gender, genderMemo: $genderMemo, icon: $icon, id: $id, imid: $imid, mobile: $mobile, '
        'name: $name, phone: $phone, signature: $signature, status: $status, sortNo: $sortNo, sortNoOpt: $sortNoOpt, '
        'timestamp: $timestamp, chatTime: $chatTime, namePinyin: $namePinyin, quanpin: $quanpin, userId: $userId, '
        'deptTreePath: $deptTreePath, officeLocation: $officeLocation, departments: $departments, '
        'departmentsString: $departmentsString, showExtra: $showExtra, dutyLevel: $dutyLevel, isSelect: $isSelect, '
        'selectStatus: $selectStatus, placeholderImage: $placeholderImage, targetString: $targetString, '
        'fullDepartmentsName: $fullDepartmentsName, companyName: $companyName, comment: $comment, nickName: $nickName, '
        'identityCard: $identityCard, extra: $extra, jobNumber: $jobNumber, username: $username, note: $note, '
        'notePinyin: $notePinyin, noteMemo: $noteMemo, company: $company, position: $position, sourceType: $sourceType, '
        'displayNameStr: $displayNameStr, onlineType: $onlineType, nameAbbr: $nameAbbr, medals: $medals, '
        'organRightFlag: $organRightFlag, contactRightFlag: $contactRightFlag, isRemote: $isRemote, '
        'finalRightFlag: $finalRightFlag, addFriendRightFlag: $addFriendRightFlag)';
  }


  final String deptId;                // 部门ID
  final String deptName;              // 部门名称
  final String dutyName;              // 职位名称
  final String email;                 // 电子邮件地址
  final String gender;                // 性别（male或female）
  final String genderMemo;            // 性别描述
  final String icon;                  // 头像URL
  final String id;                    // 员工ID
  final String imid;                  // IM系统ID
  final String mobile;                // 手机号码
  final String name;                  // 员工姓名
  final String phone;                 // 办公电话
  final String signature;             // 个性签名
  final String status;                // 状态
  final int sortNo;                   // 排序编号
  final int sortNoOpt;                // 兼职排序编号
  final int timestamp;                // 时间戳
  final int chatTime;                 // 最近聊天时间
  final String namePinyin;            // 名字的拼音
  final String quanpin;               // 名字的全拼
  final String userId;                // 第三方系统ID
  final String deptTreePath;          // 部门ID路径
  final String officeLocation;        // 办公地址
  final List<EMPABEmployeeDepartment> departments; // 员工所属的部门列表
  final String departmentsString;     // 部门信息字符串
  final String showExtra;             // 显示的额外信息
  final double dutyLevel;             // 职级
  final bool isSelect;                // 是否选中（用于UI显示）
  final int selectStatus;             // 选中状态
  final String placeholderImage;      // 占位图像（实际开发中可能需要转换为ImageProvider类型）
  final String targetString;          // 目标字符串
  final String fullDepartmentsName;   // 全部部门名称
  final String companyName;           // 公司名称
  final String comment;               // 评论或备注信息
  final String nickName;              // 昵称
  final String identityCard;          // 身份证号
  final String extra;                 // 额外信息
  final String jobNumber;             // 工号
  final String username;              // 用户名
  final String note;                  // 备注
  final String notePinyin;            // 备注的拼音
  final String noteMemo;              // 备注描述
  final String company;               // 公司
  final String position;              // 职位
  final String sourceType;            // 来源类型（内部或其他）
  final String displayNameStr;        // 显示的名称
  final int onlineType;               // 在线状态
  final String nameAbbr;              // 名字缩写
  final String medals;                // 勋章
  final int organRightFlag;           // 组织权限标志
  final int contactRightFlag;         // 联系权限标志
  final bool isRemote;                // 是否是远程查询
  final int finalRightFlag;           // 最终权限标志
  final bool addFriendRightFlag;      // 是否有添加好友的权限

  EMPABEmployeeModel({
    required this.deptId,
    required this.deptName,
    required this.dutyName,
    required this.email,
    required this.gender,
    required this.genderMemo,
    required this.icon,
    required this.id,
    required this.imid,
    required this.mobile,
    required this.name,
    required this.phone,
    required this.signature,
    required this.status,
    required this.sortNo,
    required this.sortNoOpt,
    required this.timestamp,
    required this.chatTime,
    required this.namePinyin,
    required this.quanpin,
    required this.userId,
    required this.deptTreePath,
    required this.officeLocation,
    required this.departments,
    required this.departmentsString,
    required this.showExtra,
    required this.dutyLevel,
    required this.isSelect,
    required this.selectStatus,
    required this.placeholderImage,
    required this.targetString,
    required this.fullDepartmentsName,
    required this.companyName,
    required this.comment,
    required this.nickName,
    required this.identityCard,
    required this.extra,
    required this.jobNumber,
    required this.username,
    required this.note,
    required this.notePinyin,
    required this.noteMemo,
    required this.company,
    required this.position,
    required this.sourceType,
    required this.displayNameStr,
    required this.onlineType,
    required this.nameAbbr,
    required this.medals,
    required this.organRightFlag,
    required this.contactRightFlag,
    required this.isRemote,
    required this.finalRightFlag,
    required this.addFriendRightFlag,
  });


  // 使用fromJson构造函数来从Map转换为EMPABEmployeeModel实例
  factory EMPABEmployeeModel.fromJson(Map<String, dynamic> json) {
    return EMPABEmployeeModel(
      deptId: json['deptId'] as String,
      deptName: json['deptName'] as String,
      dutyName: json['dutyName'] as String,
      email: json['email'] as String,
      gender: json['gender'] as String,
      genderMemo: json['genderMemo'] as String,
      icon: json['icon'] as String,
      id: json['id'] as String,
      imid: json['imid'] as String,
      mobile: json['mobile'] as String,
      name: json['name'] as String,
      phone: json['phone'] as String,
      signature: json['signature'] as String,
      status: json['status'] as String,
      sortNo: json['sortNo'] as int,
      sortNoOpt: json['sortNoOpt'] as int,
      timestamp: json['timestamp'] as int,
      chatTime: json['chatTime'] as int,
      namePinyin: json['namePinyin'] as String,
      quanpin: json['quanpin'] as String,
      userId: json['userId'] as String,
      deptTreePath: json['deptTreePath'] as String,
      officeLocation: json['officeLocation'] as String,
      departments: List<EMPABEmployeeDepartment>.from(json['departments'].map((x) => EMPABEmployeeDepartment.fromJson(x))),
      departmentsString: json['departmentsString'] as String,
      showExtra: json['showExtra'] as String,
      dutyLevel: json['dutyLevel'] as double,
      isSelect: json['isSelect'] as bool,
      selectStatus: json['selectStatus'] as int,
      placeholderImage: json['placeholderImage'] as String,
      targetString: json['targetString'] as String,
      fullDepartmentsName: json['fullDepartmentsName'] as String,
      companyName: json['companyName'] as String,
      comment: json['comment'] as String,
      nickName: json['nickName'] as String,
      identityCard: json['identityCard'] as String,
      extra: json['extra'] as String,
      jobNumber: json['jobNumber'] as String,
      username: json['username'] as String,
      note: json['note'] as String,
      notePinyin: json['notePinyin'] as String,
      noteMemo: json['noteMemo'] as String,
      company: json['company'] as String,
      position: json['position'] as String,
      sourceType: json['sourceType'] as String,
      displayNameStr: json['displayNameStr'] as String,
      onlineType: json['onlineType'] as int,
      nameAbbr: json['nameAbbr'] as String,
      medals: json['medals'] as String,
      organRightFlag: json['organRightFlag'] as int,
      contactRightFlag: json['contactRightFlag'] as int,
      isRemote: json['isRemote'] as bool,
      finalRightFlag: json['finalRightFlag'] as int,
      addFriendRightFlag: json['addFriendRightFlag'] as bool,
    );
  }

  // 使用toJson方法来将EMPABEmployeeModel实例转换为Map
  Map<String, dynamic> toJson() {
    return {
      'deptId': deptId,
      'deptName': deptName,
      'dutyName': dutyName,
      'email': email,
      'gender': gender,
      'genderMemo': genderMemo,
      'icon': icon,
      'id': id,
      'imid': imid,
      'mobile': mobile,
      'name': name,
      'phone': phone,
      'signature': signature,
      'status': status,
      'sortNo': sortNo,
      'sortNoOpt': sortNoOpt,
      'timestamp': timestamp,
      'chatTime': chatTime,
      'namePinyin': namePinyin,
      'quanpin': quanpin,
      'userId': userId,
      'deptTreePath': deptTreePath,
      'officeLocation': officeLocation,
      'departments': departments.map((x) => x.toJson()).toList(),
      'departmentsString': departmentsString,
      'showExtra': showExtra,
      'dutyLevel': dutyLevel,
      'isSelect': isSelect,
      'selectStatus': selectStatus,
      'placeholderImage': placeholderImage,
      'targetString': targetString,
      'fullDepartmentsName': fullDepartmentsName,
      'companyName': companyName,
      'comment': comment,
      'nickName': nickName,
      'identityCard': identityCard,
      'extra': extra,
      'jobNumber': jobNumber,
      'username': username,
      'note': note,
      'notePinyin': notePinyin,
      'noteMemo': noteMemo,
      'company': company,
      'position': position,
      'sourceType': sourceType,
      'displayNameStr': displayNameStr,
      'onlineType': onlineType,
      'nameAbbr': nameAbbr,
      'medals': medals,
      'organRightFlag': organRightFlag,
      'contactRightFlag': contactRightFlag,
      'isRemote': isRemote,
      'finalRightFlag': finalRightFlag,
      'addFriendRightFlag': addFriendRightFlag,
    };
  }
}
